from PyQt6.QtCore import Qt
from PyQt6.QtWidgets import QApplication, QMainWindow, QDockWidget, QVBoxLayout, QLabel, QLineEdit, QPushButton, QWidget


class DeviceSettingPanel(QDockWidget):
	def __init__(self, parent=None):
		super().__init__(parent)
		self.setWindowTitle("Device Setting")
		self.setup_ui()
		# 设置边框样式表
		self.setStyleSheet("border: 1px solid black; ")
		#self.setMaximumWidth(300)  # 设置最大宽度为300像素

	def setup_ui(self):
		self.layout = QVBoxLayout()

		self.device_name_label = QLabel("Device Name:")
		self.device_name_edit = QLineEdit()

		self.save_button = QPushButton("Save")
		self.save_button.clicked.connect(self.save_settings)

		self.layout.addWidget(self.device_name_label)
		self.layout.addWidget(self.device_name_edit)
		self.layout.addWidget(self.save_button)

		widget = QWidget()
		widget.setLayout(self.layout)

		self.setWidget(widget)

	def save_settings(self):
		device_name = self.device_name_edit.text()
		# Save device settings logic goes here
		print(f"Saving settings for device: {device_name}")


# Example usage
if __name__ == "__main__":
	import sys

	app = QApplication(sys.argv)
	main_window = QMainWindow()
	dock = DeviceSettingPanel()
	main_window.addDockWidget(Qt.DockWidgetArea.LeftDockWidgetArea, dock)
	main_window.show()
	sys.exit(app.exec())
